package com.bins.dentist.clinic.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bins.dentist.clinic.model.dto.UserGroupDto;
import com.bins.dentist.clinic.model.dto.UserGroupPageDto;
import com.bins.dentist.clinic.model.vo.ResultVo;
import com.bins.dentist.clinic.model.vo.UserGroupVo;
import com.bins.dentist.clinic.service.UserGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bins
 * @since 2023-02-20 20:53:31
 */
@RestController
@RequestMapping("/system/userGroup")
public class UserGroupController {

    @Autowired
    private UserGroupService userGroupService;

    @GetMapping("/page")
    public ResultVo<IPage<UserGroupVo>> pageList(UserGroupPageDto pageDto) {
        return ResultVo.ok().data(userGroupService.getPage(pageDto));
    }

    @GetMapping("/detail")
    public ResultVo<UserGroupVo> detail(UserGroupDto dto) {
        return ResultVo.ok().data(userGroupService.getDetailById(dto));
    }

    @PostMapping("/save")
    public ResultVo<UserGroupVo> saveUserGroup(@RequestBody UserGroupDto dto) {
        return ResultVo.ok().data(userGroupService.saveUserGroup(dto));
    }

    @PostMapping("/delete")
    public ResultVo<Boolean> deleteUserGroup(@RequestBody UserGroupDto dto){
        return ResultVo.ok().data(userGroupService.deleteUserGroup(dto)) ;
    }
}

